package com.leoman.dao;

import com.leoman.entity.Praise;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * PraiseDao
 * Created by 涂奕恒 on 2016/11/23 0023 下午 3:44.
 */
public interface PraiseDao extends JpaRepository<Praise, Integer>, JpaSpecificationExecutor<Praise> {

    @Query("select a from Praise a where a.user.id = ?1 and a.sourceId = ?2 and a.sourceType = ?3")
    Praise findOneByParams(Integer userId, Integer sourceId, Integer type);

    @Query("select a from Praise a where a.sourceId = ?1 and a.sourceType = ?2")
    List<Praise> findListBySourceIdAndType(Integer sourceId, Integer type);
}